using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Utility;
using DTO;

namespace BUS
{
   public class tbsanphamBUS
    {
        public static tbsanphamcollection Get(string where,
        int pageindex,
        int pagesize,
        string orderby,
        string orderdirection,
        out int total)
        {
            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            return sanphamDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbsanphamcollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            return sanphamDAL.Get(cri.Criter, 0, 0, sanphamcolumns.masanpham.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbsanpham GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, sanphamcolumns.masanpham.ToString(), Condition.EQUAL, iD);
            tbsanphamDAL sanphamDAL = new tbsanphamDAL();
            tbsanphamcollection sanphamcollection = sanphamDAL.Get(cri.Criter,
                     0, 0, sanphamcolumns.masanpham.ToString(), OrderDirection.ASC.ToString(), out total);
            if (sanphamcollection.Count > 0)
                return sanphamcollection[0];
            return null;
        }
    }
}
